package com.wkbb.sports.dto;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.wkbb.common.utils.DoubleUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.text.DecimalFormat;

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class ChartDto {
    @ApiModelProperty(value = "描述")
    private String desc;
    @ApiModelProperty(value = "序号")
    private float index;
    @ApiModelProperty(value = "值")
    private float value = 0;
    @ApiModelProperty(value = "百分比")
    private int percentage = 0;

    public void addValue(){
        value++;
    }

    public void calcPercentage(int total){
        if (value > 0){
            percentage = DoubleUtil.ratio(value/total);
        }
    }

}
